
/****** Object:  StoredProcedure [dbo].[web_change_card_status]    Script Date: 10/19/2013 09:22:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

--IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'web_change_card_status')
DROP PROCEDURE web_change_card_status
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[web_change_card_status] 
	@type varchar(50),
	@action varchar(50),
	@imkodas varchar(100),
	@kortele varchar(100)
AS
BEGIN

	SET NOCOUNT ON
	
	If (@type = 'TIEK_BLOK')
		If (@action='BLOCK')
			UPDATE N51_SUTH set N51_VISKAS ='1' , N51_kodas_ls_1 = 'TIEK_BLOK' where N51_KODAS_KT=@kortele
		else
			UPDATE N51_SUTH set N51_VISKAS ='0' , N51_kodas_ls_1 = '' where N51_KODAS_KT=@kortele
			
	else
		If (@action='BLOCK')
			UPDATE N51_SUTH set N51_VISKAS ='1' , N51_kodas_ls_1 = 'KLIENT_BLOK' where N51_KODAS_KT=@kortele AND N51_kodas_ls_1 = '' and N51_KODAS_KS=@imkodas
		else
			UPDATE N51_SUTH set N51_VISKAS ='0' , N51_kodas_ls_1 = '' where N51_KODAS_KT=@kortele AND N51_kodas_ls_1 = 'KLIENT_BLOK' and N51_KODAS_KS=@imkodas
	
	

END

GO

